<?php

namespace App\Service\Dao;

use App\ENUM\ENUM_IS_SHOW;
use App\ENUM\ENUM_PAGE;
use App\Model\Article;
use App\Model\ArticleColumn;
use App\Model\ArticleContent;
use App\Service\ArticleService;

class ArticleDao
{

    public function getArticleList($where, $page_size = ENUM_PAGE::PAGE_SIZE)
    {
        return Article::with(['getColumn', 'getLabel'])->where($where)->paginate($page_size);
    }

    public function getArticleDetail($where)
    {
        $article = Article::with(['getLabel', 'getContent'])->where($where)->first();
        if (!empty($article)) {
            return $article;
        }
        return [];
    }

    public function getArticleColumn()
    {
        $column = ArticleColumn::where('is_show', ENUM_IS_SHOW::SHOW)->get();

        if (!empty($column)) {
            return $column;
        }
        return [];
    }

    public function articleColumnMessage($id)
    {
        $column = ArticleColumn::where('id', $id)->first();

        if (!empty($column)) {
            return $column;
        }
        return [];
    }

}